package com.df.gameai.modules.tools;

import dev.langchain4j.agent.tool.P;
import dev.langchain4j.agent.tool.Tool;
import org.springframework.stereotype.Component;

import java.io.IOException;
import java.nio.file.Files;
import java.nio.file.Path;

@Component
public class GameAiTools {
    @Tool(name = "writeFile" ,
            value = "保存字符串到本地文件，path为要保存的路径，content为要保存的字符串，返回字符串1表示写入成功，否则返回内容为失败原因"
    )
    public String writeFile(@P("保存的路径") String path,@P("保存的内容") String content){
        try {
            System.out.println(2);
            Files.writeString(Path.of(path),content);
        } catch (IOException e) {
            e.printStackTrace();
            return e.getMessage();
        }
        return "1";
    }
}
